<template>
    <div>
        <div style="height: 100%;box-sizing: border-box;">
            <a-row>
                <a-col :span="8">
                    <a-form-item :label="$ti18('rxForm.constantVar', '常量')" :label-col="{span:4}" :wrapper-col="{span:20}">
                        <a-select id="fieldType" v-model="fieldType" style="width: 80%" @change="constChangeType" allowClear>
                            <a-select-option v-for="item in constList" :key="item.id" :value="item.id">{{item.value}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>
                </a-col>
                <a-col :span="8">
                    <a-form-item :label="$comi18('rxDialog.fieldSelect', '字段选择')"  :labelCol="{span:7}" :wrapperCol="{span:17}">
                        <a-select  style="width: 80%" @change="defChangeType" allowClear>
                            <a-select-option v-for="item in attrList"
                                             :key="item.name" :value="item.name">{{item.comment}}
                            </a-select-option>
                        </a-select>
                    </a-form-item>
                </a-col>

                <a-col :span="8">

                    <a-button icon="edit" @click="showScriptDialog()">
                        {{i18n('form.quickScript','快速脚本')}}
                    </a-button>

                </a-col>

            </a-row>
        </div>
    </div>

</template>

<script>

    import {Util,RxLayout,RxDialog,RxFit,RxGrid,Dialog} from "@lowcode/jpaas-common-lib"

    import FormCustomQueryApi  from "@/api/form/core/formCustomQuery";


    export default {
        name: 'rx-process-handle-dialog',

        components: {
            RxLayout,
            RxDialog,
            RxGrid,
            RxFit,

        },
        props: {
            layerid: {
                type: String,
                default: ""
            },
            destroy: {
                type: Function
            },
            /**
             * 属性字段
             */
            attrList: {
                type: Array,
                default: []
            },
        },
        created() {
            this.getConstants();
        },
        data() {
            return {

                fieldType: "",
                commonType: "",
                constList: [],
            }
        },
        methods: {
            i18n(name,text,key){
                return this.$ti18(name,text,"formPermiss",key);
            },
            getConstants() {
                FormCustomQueryApi.getConstants().then(data=>{
                    var ary=data.map(item => {
                        return { value: item.val, id: item.key }
                    })
                    this.constList=ary;
                })
            },
            constChangeType(e){
                this.$emit("selectType", e);
            },
            defChangeType(e) {
                e="model."+e;
                this.$emit("selectType", e);
            },
            handOk() {
                Util.closeWindow(this, "ok");
            },
            getData() {
                return this.monacoValue;
            },
            showScriptDialog(){
                let self=this;
                let config={curVm:this};
                Dialog.openScriptDialog(config,function (script){
                    self.$emit("selectType", script);
                })
            },
        }
    }
</script>
<style scoped>

</style>

